

export const state = () => ({
    history:[]
  })

export const mutations = {
    setHistory(state,data){
        const index = state.history.findIndex(v => {
              if (
                v.departCity === data.departCity
                && v.destCity === data.destCity
                && v.departDate === data.departDate) {
                // 重复了 
                return true
              } else {
                return false;
              }
            });
        
            if (index !== -1) {
              // 找到了 先删除
              state.history.splice(index, 1);
            }
          
        state.history.unshift(data)
    }
}